package com.ydl.shopping.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ydl.shopping.domain.TbGoods;
import com.ydl.shopping.mapper.TbGoodsMapper;
import com.ydl.shopping.service.ITbGoodsService;
import org.springframework.stereotype.Service;

@Service
public class TbGoodsServiceImpl extends ServiceImpl<TbGoodsMapper, TbGoods> implements ITbGoodsService {
    @Override
    public QueryWrapper<TbGoods> queryWrapper(TbGoods entity) {
        QueryWrapper<TbGoods> queryWrapper = new QueryWrapper<>();
        String name = entity.getName();
        if (StrUtil.isNotBlank(name)) {
            queryWrapper.like("name", name);
        }
        Integer isUp = entity.getIsUp();
        if (isUp != null) {
            queryWrapper.eq("is_up", isUp);
        }
        Integer isRecommend = entity.getIsRecommend();
        if (isRecommend != null) {
            queryWrapper.eq("is_recommend", isRecommend);
        }
        Integer status = entity.getStatus();
        if (status != null) {
            queryWrapper.eq("status", status);
        }

        return queryWrapper;
    }
}
